package com.example.multitenant.multitenant.controller

import com.example.multitenant.multitenant.model.Tenant
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RestController

/**
 * @author xiang
 * @Date 2022/8/29 22:44
 **/

@RestController
class TenantController {

    @Autowired
    private lateinit var service: TenantService

    @PostMapping("/tenant")
    fun addTenant(groupId: String, dbName: String): String {
        service.addTenant(groupId, dbName)
        return "success"
    }

    @GetMapping("/tenant")
    fun getTenants(): List<Tenant> {
        return service.getTenants()
    }

}